<template>
    <div class="chart-index">
        <Chart :cdata="cdata"/>
    </div>
</template>

<script>
import Chart from './chart.vue';

export default {
    data() {
        return {
            first: true,
            drawTiming: null,
            cdata: {
                category: [],
                legends:[],
                seriesData: [],
            }
        };
    },
    props: {
        intervalDuration: {
            type: Number,
            default: () => (6000)
        },
        enableInterval: {
            type: Boolean,
            default: true,
        },
    },
    components: {
        Chart,
    },
    mounted() {
    },
    beforeDestroy() {
        clearInterval(this.drawTiming);
    },
    methods: {
        // 根据自己的业务情况修改
        setData(from) {
            let that = this;
            let category = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期天",];
            let legends = ["订制单", "交接单"];
            that.cdata = that.selfUtils.initChartData(category, legends, [1, 300]);
            if (from) {
                setTimeout(()=>{
                    from.loading = false;
                },1000)
            }
        },
    },
    watch: {
        enableInterval: {
            handler(newV) {
                this.selfUtils.drawTimingFn(this, this.intervalDuration, newV, this.first);
            },
            immediate: true,
            deep: true,
        },
        intervalDuration: {
            handler(newV) {
                this.$parent.toggleCountDown();
                this.selfUtils.drawTimingFn(this, newV, this.enableInterval, this.first);
            },
            // immediate: true,
            deep: true,
        }
    },
};
</script>

<style lang="scss" scoped>
</style>